package com.ibeeking.found.content.b.rest.controller.v1;



import com.ibeeking.found.common.enums.CommonDataTypeEnum;
import com.ibeeking.found.content.b.rest.service.*;
import com.ibeeking.found.content.service.common.param.*;
import com.ibeeking.found.content.service.common.query.*;
import com.ibeeking.found.content.service.common.vo.*;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName ArticleController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/b/article/v1")
public class ArticleController {

    @Resource
    private IArticleService articleServiceImpl;
    @Resource
    private IArticleAuthorService articleAuthorServiceImpl;
    @Resource
    private IArticleGroupService articleGroupServiceImpl;
    @Resource
    private IArticleCommentService articleCommentServiceImpl;


    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章列表")
    @PostMapping(value = "/list")
    public List<ArticleVO> list(@RequestBody ArticleQuery articleQuery) {
        return articleServiceImpl.list(articleQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章分页列表")
    @PostMapping(value = "/pageList")
    public Page<ArticleVO> pageList(@RequestBody ArticlePageQuery articlePageQuery) {
        return articleServiceImpl.pageList(articlePageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "文章添加")
    @PostMapping(value = "/add")
    public Boolean add(@RequestBody @Validated ArticleParam articleParam) {
        return articleServiceImpl.add(articleParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章修改")
    @PostMapping(value = "/modify")
    public Boolean modify(@RequestBody @Validated ArticleParam articleParam) {
        return articleServiceImpl.modify(articleParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章查看")
    @GetMapping(value = "/view/{id}")
    public ArticleVO view(@PathVariable("id") Long id) {
        return articleServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章公开状态修改")
    @GetMapping(value = "/changeStatus/{id}/{status}")
    public Boolean changeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return articleServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章置顶状态修改")
    @GetMapping(value = "/changePutTopStatus/{id}/{status}")
    public Boolean changePutTopStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return articleServiceImpl.changePutTopStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "文章删除")
    @GetMapping(value = "/del/{id}")
    public Boolean del(@PathVariable("id") Long id) {
        return articleServiceImpl.del(id);
    }

    /**
     * --------文章作者
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章作者有效列表")
    @PostMapping(value = "/author/list")
    public List<ArticleAuthorVO> authorList(@RequestBody ArticleAuthorQuery articleAuthorQuery) {
        return articleAuthorServiceImpl.list(articleAuthorQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章作者分页列表")
    @PostMapping(value = "/author/pageList")
    public Page<ArticleAuthorVO> authorPageList(@RequestBody ArticleAuthorPageQuery articleAuthorPageQuery) {
        return articleAuthorServiceImpl.pageList(articleAuthorPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "文章作者添加")
    @PostMapping(value = "/author/add")
    public Boolean authorAdd(@RequestBody @Validated ArticleAuthorParam articleAuthorParam) {
        return articleAuthorServiceImpl.add(articleAuthorParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章作者修改")
    @PostMapping(value = "/author/modify")
    public Boolean authorModify(@RequestBody @Validated ArticleAuthorParam articleAuthorParam) {
        return articleAuthorServiceImpl.modify(articleAuthorParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章作者查看")
    @GetMapping(value = "/author/view/{id}")
    public ArticleAuthorVO authorView(@PathVariable("id") Long id) {
        return articleAuthorServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "文章作者删除")
    @GetMapping(value = "/author/del/{id}")
    public Boolean authorDel(@PathVariable("id") Long id) {
        return articleAuthorServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章作者状态修改")
    @GetMapping(value = "/author/changeStatus/{id}/{status}")
    public Boolean authorChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return articleAuthorServiceImpl.changeStatus(id, status);
    }

    /**
     * ------------文章分组
     */

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章分组列表")
    @PostMapping(value = "/group/list")
    public List<ArticleGroupVO> groupList(@RequestBody ArticleGroupQuery articleGroupQuery) {
        return articleGroupServiceImpl.list(articleGroupQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章分组分页列表")
    @PostMapping(value = "/group/pageList")
    public Page<ArticleGroupVO> groupPageList(@RequestBody ArticleGroupPageQuery articleGroupPageQuery) {
        return articleGroupServiceImpl.pageList(articleGroupPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "文章分组添加")
    @PostMapping(value = "/group/add")
    public Boolean groupAdd(@RequestBody @Validated ArticleGroupParam articleGroupParam) {
        return articleGroupServiceImpl.add(articleGroupParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "文章分组修改")
    @PostMapping(value = "/group/modify")
    public Boolean groupModify(@RequestBody @Validated ArticleGroupParam articleGroupParam) {
        return articleGroupServiceImpl.modify(articleGroupParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "文章分组查看")
    @GetMapping(value = "/group/view/{id}")
    public ArticleGroupVO groupView(@PathVariable("id") Long id) {
        return articleGroupServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "文章分组删除")
    @GetMapping(value = "/group/del/{id}")
    public Boolean groupDel(@PathVariable("id") Long id) {
        return articleGroupServiceImpl.del(id);
    }

    /**
     * 评论管理
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论分页列表")
    @PostMapping(value = "/comment/pageList")
    public Page<ArticleCommentVO> commentPageList(@RequestBody ArticleCommentPageQuery articleCommentPageQuery) {
        return articleCommentServiceImpl.pageList(articleCommentPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论查看")
    @GetMapping(value = "/comment/view/{id}")
    public ArticleCommentVO commentView(@PathVariable("id") Long id) {
        return articleCommentServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "评论公开状态修改")
    @GetMapping(value = "/comment/changeStatus/{id}/{status}")
    public Boolean commentChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return articleCommentServiceImpl.changeStatus(id, status);
    }

}
